package server.net.handler;

import java.nio.ByteBuffer;
import server.net.Client;

/**
 * This class handles pong responses from the client.
 *
 * @author Vincent Tsuei
 * @author Andrew Gratta
 * @version 11/21/12
 */
public class PongHandler implements ServerPacketHandler {

    public PongHandler() {}
    
    @Override
    public int processPacket(Client client, ByteBuffer packet) {
        if (client == null || packet == null)
        {
            return -1;
        }
        if (!client.isExpectingPong()) {
            return 0; //Ignore the packet if we are not expecting a pong.
                      //Don't return an error. It's not a big deal.
        }
        client.pongReceived(packet.getInt());
        return 0;
    }
    
}
